package com.ss.android.lockscreen.activity.lock;

import android.support.v4.view.ViewPager;

import com.ss.android.lockscreen.bb;
import com.ss.android.lockscreen.http.data.ScreenCell.Type;
import com.ss.android.lockscreen.http.data.ScreenCell;
import org.json.JSONException;
import org.json.JSONObject;

final class h extends ViewPager.SimpleOnPageChangeListener {
    private final LockScreenActivity b;
    private int a;

    h(LockScreenActivity arg2) {
        this.b = arg2;

        this.a = 0;
    }

    public final void onPageScrollStateChanged(int state) {
        int v2;
        int v3 = -1;
        super.onPageScrollStateChanged(state);
        if(state == 0) {
            LockScreenActivity.k(this.b);
            w v4 = LockScreenActivity.m(this.b);
            ScreenCell v5 = LockScreenActivity.l(this.b);
            if(v5 == null || v4.b == null) {
                v2 = v3;
            }
            else {
                int v0 = 0;
                v2 = v3;
                while(v0 < v4.b.size()) {
                    if(v4.b.get(v0) == v5) {
                        v2 = v0;
                    }

                    ++v0;
                }

                if(v2 == v3) {
                }else {
                    v4.b.remove(v2);
                    v4.c(v2);
                }
            }

            if(v2 == v3) {
                return;
            }

            LockScreenActivity.a(this.b).setCurrentItem(v2, false);
            LockScreenActivity.n(this.b);
            LockScreenActivity.a(this.b, v2);
        }
    }

    public final void onPageSelected(int position) {
        String v0_1;
        String v3;
        JSONObject v2;
        LockScreenActivity.a(this.b, position);
        ScreenCell v1 = LockScreenActivity.m(this.b).b(position);
        if(this.a != position && v1 != null) {
            if(!LockScreenActivity.o(this.b)) {
                if(bb.a().f != null) {
                    v2 = new JSONObject();
                    try {
                        v3 = "action";
                        v0_1 = this.a < position ? "switch_right" : "switch_left";
                        v2.put(v3, v0_1);
                        v2.put("group_id", String.valueOf(v1.f));
                        v2.put("item_id", String.valueOf(v1.g));
                        if(v1.b == Type.LittleVideo) {
                            v2.put("group_type", "little_video");
                        }else {
                            v3 = "group_type";
                            v0_1 = v1.i ? "video" : "article";
                            v2.put(v3, v0_1);
                        }
                    }
                    catch(JSONException v0) {
                        v0.printStackTrace();
                    }

                    android.support.design.a.onEvent("lockscreen_picture", v2);
                }

                if(bb.a().f == null) {
                }else {
                    v2 = new JSONObject();
                    try {
                        v2.put("group_id", String.valueOf(v1.f));
                        v2.put("item_id", String.valueOf(v1.g));
                        if (v1.b == Type.LittleVideo) {
                            v2.put("group_type", "little_video");
                        } else {
                            v3 = "group_type";
                            v0_1 = v1.i ? "video" : "article";
                            v2.put(v3, v0_1);
                        }
                    } catch (JSONException v0) {
                        v0.printStackTrace();
                    }
                    android.support.design.a.onEvent("lockscreen_show", v2);
                }
            }

            android.support.design.a.B.a(v1.f);
            this.a = position;
        }
    }
}

